<?php

namespace App\Models;

class Cancel extends BaseModel
{
  public function seller()
  {
    return $this->belongsTo(User::class, 'seller_id');
  }

  public function scopeWhenSellerName($q, $name)
  {
    $q->when($name, function ($q) use ($name) {
      $q->whereHas('seller', function ($q) use ($name) {
        $q->whereHas('user', function ($q) use ($name) {
          $q->where('username', $name);
        });
      });
    });
  }
}
